package com.ag.dgm.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;


import com.ag.bean.TbPlanType;
import com.ag.common.BaseAction;
import com.ag.common.IDUtil;

import com.ag.dgm.service.PlanTypeService;

@Controller("PlanTypeAction")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class PlanTypeAction extends BaseAction {
	private static final long serialVersionUID = 3376692310000868090L;

	@Resource(name="planTypeService")
	private PlanTypeService planTypeService;
	private List<TbPlanType> tbPlanTypeList;
	private String Id;
	private String Name;
	private String Detail;
	private String result;
	TbPlanType tbPlanType = new TbPlanType();



	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}



	public void setTbPlanTypeList(List<TbPlanType> tbPlanTypeList) {
		this.tbPlanTypeList = tbPlanTypeList;
	}


	public List<TbPlanType> getTbPlanTypeList() {
		return tbPlanTypeList;
	}

	public String getId() {
		return Id;
	}

	public void setId(String Id) {
		this.Id = Id;
	}

	public String getName() {
		return Name;
	}

	public void setName(String Name) {
		this.Name = Name;
	}

	public String getDetail() {
		return Detail;
	}

	public void setDetail(String Detail) {
		this.Detail = Detail;
	}
	
	
	public String find() {
		tbPlanTypeList = planTypeService.find();
		return "main";
	}

	public String modify() {
		tbPlanType.setPtId(Id);
		tbPlanType.setPtDetail(Detail);
		tbPlanType.setPtName(Name);
		tbPlanType.setA(IDUtil.PRESERVE);
		this.setResult("修改成功");
		try {
			planTypeService.modify(tbPlanType);
		} catch (Exception e) {
			this.setResult("修改不成功");
		}
		return "modify_succ";
		
	}

	public String delete() {
		tbPlanType.setPtId(Id);
		this.setResult("删除成功");
	
			planTypeService.delete(tbPlanType);
	
		
		return "delete_succ";
	}

	public String add() {
		tbPlanType.setPtDetail(Detail);
		tbPlanType.setPtName(Name);
		tbPlanType.setA(IDUtil.PRESERVE);
		this.setResult("增加成功");
		try {
			planTypeService.add(tbPlanType);
		} catch (Exception e) {
			this.setResult("增加不成功");
		}
		return "add_succ";
		
	}

}
